package com.loan.market.view

import android.content.Context
import android.util.AttributeSet
import android.view.Gravity
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.content.withStyledAttributes
import com.loan.market.R

class SettingBar @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null
) : LinearLayout(context, attrs) {

    private var tvLeft: TextView
    private var tvRight: TextView

    init {
        orientation = HORIZONTAL
        gravity = Gravity.CENTER_VERTICAL
        inflate(context, R.layout.layout_setting_bar, this)
        tvLeft = findViewById(R.id.tv_left)
        tvRight = findViewById(R.id.tv_right)
        context.withStyledAttributes(attrs, R.styleable.SettingBar) {
            tvLeft.text = getString(R.styleable.SettingBar_leftText)
            tvRight.text = getString(R.styleable.SettingBar_rightText)
        }
    }

    fun setRightText(text: String?) {
        tvRight.text = text
    }

}